#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n,l,r;

int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	
	scanf("%d%d%d",&n,&l,&r);
	int ml=l%n;
	int mr=r%n;
	if(r-l>=n){
		printf("%d",n-1);
		return 0;
	}
	if(ml<=mr){
		printf("%d",mr);
		return 0;
	}
	printf("%d",n-1);
	return 0;
}

